package com.xuecheng.content.convert;

import com.xuecheng.api.content.model.dto.CourseBaseDTO;
import com.xuecheng.api.content.model.vo.CourseAuditVO;
import com.xuecheng.api.content.model.vo.CourseBaseVO;
import com.xuecheng.content.entity.CourseBase;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper
public interface CourseBaseConverrt {

    CourseBaseConverrt INSTANCE= Mappers.getMapper(CourseBaseConverrt.class);

    //mapping注解只能加载单个属性转换方法上，放到下面不生效
    @Mappings({
        @Mapping(source = "id",target = "courseBaseId")
    })
    CourseBaseDTO entity2dto(CourseBase courseBase);


    @Mappings({
            @Mapping(source = "courseBaseId",target = "id")
    })
    CourseBase dto2entity(CourseBaseDTO dto);



    CourseBaseDTO vo2dto(CourseBaseVO vo);

    /**
     * 集合数据的转换需要依赖单个数据的转换方法
     * @param courseBases
     * @return
     */
    List<CourseBaseDTO> entitys2dtos(List<CourseBase> courseBases);

    CourseBaseDTO audit2dto(CourseAuditVO auditVO);

}
